package ssm.blog.service.impl;

import org.springframework.stereotype.Service;
import ssm.blog.dao.ContactMsgMapper;
import ssm.blog.entity.ContactMsg;
import ssm.blog.entity.ContactMsgExample;
import ssm.blog.service.ContactMsgService;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: lyon
 * @description: 联系我服务层
 * @author: Lyon
 * @create: 2018-06-06 22:26
 **/
@Service
public class ContactMsgServiceImpl implements ContactMsgService {
    @Resource
    ContactMsgMapper mapper;
    @Override
    public int add(ContactMsg msg) {
        return mapper.insertSelective(msg);
    }

    @Override
    public List<ContactMsg> listByKeyword(String keyword) {
        ContactMsgExample example=new ContactMsgExample();
        example.setOrderByClause("id desc");
        example.createCriteria().andNameLike("%"+keyword+"%");
        return mapper.selectByExample(example);
    }

    @Override
    public int count() {
        ContactMsgExample example=new ContactMsgExample();
        return mapper.countByExample(example);
    }

    @Override
    public int dele(Integer id) {
        return mapper.deleteByPrimaryKey(id);
    }
    @Override
    public int deles(List<Integer> ids) {
        ContactMsgExample example=new ContactMsgExample();
        example.createCriteria().andIdIn(ids);
        return mapper.deleteByExample(example);
    }
}
